package com.bjsxt.mapper;

import com.bjsxt.pojo.Menu;
import com.bjsxt.pojo.TreeA;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MenuMapper {
    //查询指定用户下的菜单   异步树TreeA
    @Select("SELECT  * FROM  t_menu where mid in(SELECT mid  FROM  t_role_menu  where rid in(SELECT rid FROM t_admin_role where aid=#{param1}) ) and pid=#{param2}")
    List<Menu> selectMore(Integer aid,Integer pid);

    //查询菜单信息响应到数据网格中   PageA
    @Select("select *  from t_menu")
    List<Menu>   selectAll();

    //查询菜单与用户的权限无关  异步树  TreeA
    @Select("select *  from t_menu where pid=#{param1}")
    List<Menu> selectMore2(Integer pid);
    //添加菜单信息
    @Insert("insert into t_menu(mname,pid,status,url,mdesc) values(#{mname},#{pid},#{status},#{url},#{mdesc})")
    Integer insert(Menu menu);

    //修改菜单数据
     @Update("update t_menu set mname=#{mname},pid=#{pid},status=#{status},url=#{url},mdesc=#{mdesc} where mid=#{mid}")
    Integer update(Menu menu);
     //删除菜单数据
    @Delete("delete from t_menu where mid=#{mid}")
    Integer delete(Integer mid);

    //查询同步树的菜单信息   TreeA 包含子节点树
    List<TreeA> selectMore3(Integer pid);


}
